﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //jion();
            //jion2();
            //jion3();
            //jion4();
            //jion5();
            //jion6();
            jion7();
        }
        public static void jion()
        {
            //用户输入正方形边长，用* 打印出实心正方形。
            Console.WriteLine("请输入正方形的边长：");
            int a = int.Parse(Console.ReadLine());
            string[,] arr = new string[a, a];
            for (int i = 0; i < a; i++)
            {
                for (int j = 0; j < a; j++)
                {
                    arr[i, j] = "* ";
                }

            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();
            }
        }
        public static void jion2()
        {
            //九九乘法表
            //for (int i = 1; i <= 9; i++)
            //{
            //    for (int j = 1; j <= i; j++)
            //    {
            //        Console.Write(i+"*"+j+"="+i*j+"\t");
            //    }
            //    Console.WriteLine();
            //}
            string[,] arr = new string[9, 9];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    arr[i, j] = (i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1) + "\t";
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();
            }
        }
        public static void jion3()
        {
            //用户输入正方形边长，用* 打印出空心正方形。
            Console.WriteLine("输入正方形的边长：");
            int a = int.Parse(Console.ReadLine());
            string[,] arr = new string[a, a];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (j == 0 || j == a - 1)
                    {
                        arr[i, j] = "* ";
                    }
                    else if (i == 0 || i == a - 1)
                    {
                        arr[i, j] = "* ";
                    }
                    else
                    {
                        arr[i, j] = "  ";
                    }
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();
            }

        }
        public static void jion4()
        {
            Console.WriteLine("请输入菱形边长：");
            int b = int.Parse(Console.ReadLine());

            string[,] a = new string[b * 2 - 1, 2 * b - 1];

            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    if (i == 0)
                    {
                        if (j == b - 1)
                        {
                            a[i, j] = "*";
                        }
                        else
                        {
                            a[i, j] = " ";
                        }

                    }
                    else if (i <= b - 1)
                    {
                        if (j <= b - 1 + i && j >= b - 1 - i)
                        {
                            a[i, j] = "*";
                        }
                        else
                        {
                            a[i, j] = " ";
                        }
                    }
                    else

                    {
                        if (j >= i - b + 1 && j <= 2 * b - 1 - (i - b + 2))
                        {
                            a[i, j] = "*";
                        }
                        else
                        {
                            a[i, j] = " ";
                        }


                    }

                }


            }


            for (int i = 0; i < a.GetLength(0); i++)
            {
                for (int j = 0; j < a.GetLength(1); j++)
                {
                    Console.Write(a[i, j]);

                }
                Console.WriteLine("");
            }

        }
        public static void jion5()
        {
            // 打印杨辉三角形（要求打印10行），如下所示：（使用二维数组）
            int[,] arr = new int[10, 10];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (j == 0)
                    {
                        arr[i, 0] = 1;
                    }
                    else if (i == j)
                    {
                        arr[i, j] = 1;
                    }
                    else if (i < j)
                    {

                    }
                    else
                    {
                        arr[i, j] = arr[i - 1, j - 1] + arr[i - 1, j];
                    }


                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (arr[i, j] != 0)
                    {
                        Console.Write(arr[i, j] + "\t");
                    }


                }
                Console.WriteLine();
            }
        }
        public static void jion6()
        {
            //如果一个数组保存元素是有序的（从大到小），向这个数组中插入一个数，使得插入后的数组元素仍然保持有序。
            int[] arr = { 99, 66, 54, 32, 21, 0 };
            int[] arr2 = new int[arr.Length + 1];
            Console.WriteLine("请添加一个数字");
            arr2[arr.Length] = int.Parse(Console.ReadLine());

            for (int i = 0; i < arr2.Length; i++)
            {
                if (i < arr.Length)
                {
                    arr2[i] = arr[i];
                }
            }
            Array.Sort(arr2);
            Array.Reverse(arr2);
            foreach (var item in arr2)
            {
                Console.Write(item + " ");
            }

        }
        public static void jion7()
        {
            /*在 Main 方法中创建一个字符串类型的数组，并存入 5 个值，然后将数组中下标是偶数的元素输出*/
            string[] str = { "1", "2", "3", "4", "5" };
            for (int i = 0; i < str.Length; i++)
            {
                if (i % 2 == 0)
                {
                    Console.Write(str[i] + "\t");
                }
            }
            Console.WriteLine();
        }
    }
}
